User:I JethroBT/global.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:I JethroBT/global. |
// ==UserScript==
// @name GFS Factual Consensus Finder Link for Wikimedia Pages
// @description GFS Factual Consensus Finder Link for Wikimedia Pages
// @author modified by Johannes Frey from oringinal DBpedia script by Anja Jentzsch
// @namespace none
// @include http://*.wikipedia.org/wiki/*
// ==/UserScript==
var allHTMLTags = new Array();
function getElementByClass(theClass) {
var allHTMLTags=document.getElementsByTagName('li');
for (i=0; i<allHTMLTags.length; i++) {
if (allHTMLTags[i].className == theClass) {
var link = allHTMLTags[i].firstChild.getAttribute("href");
if(link.search('en.wikipedia.org') > -1) {
return link;
}
}
}
return "";
}
var gfs_fcs = location.href.replace(/https?:\/\/www.wikidata.org\/wiki/,"http://www.wikidata.org/entity");
gfs_fcs = "https://global.dbpedia.org/?s=" + encodeURIComponent(decodeURIComponent(gfs_fcs));
addIconNextToTitle(gfs_fcs,"https://upload.wikimedia.org/wikipedia/commons/a/ae/73424-sync-symbol.svg","Show GFS Factual Consensus Finder");
var ref_extractor = "http://dbpedia.informatik.uni-leipzig.de:8111/infobox/references?article="+encodeURIComponent(decodeURIComponent(location.href))+"&format=json&dbpedia";
addIconNextToTitle(ref_extractor,"https://de.wikibooks.org/favicon.ico","Referenced Facts Extraction Microservice");
function addIconNextToTitle(url,img_url,hover_text) {
{
var firstHeading, dbpediaLink, pageTitle, hostName;
pageTitle = location.pathname.replace(/\/wiki/, "");
if (pageTitle.length > 0) {
firstHeading = document.getElementById('firstHeading');
dbpediaLink = document.createElement("a");
dbpediaLink.setAttribute("style","margin-left: 20px;");
dbpediaLink.setAttribute("href",url);
dbpediaImage = document.createElement("img");
dbpediaImage.setAttribute("style","border:none; height:1em;");
dbpediaImage.setAttribute("title",hover_text+" for " + firstHeading.firstChild.nodeValue);
dbpediaImage.setAttribute("src",img_url);
dbpediaLink.appendChild(dbpediaImage);
firstHeading.appendChild(dbpediaLink);
}
}
/*
} else {
var englishLink = getElementByClass('interwiki-en');
var link = "";
if(englishLink.search('en.wikipedia.org') > -1) {
link = englishLink;
} else {
link = getElementByClass('interwiki-en GA');
}
if(link.search('en.wikipedia.org') > -1) {
if (pageTitle.length > 0) {
firstHeading = document.getElementById('firstHeading');
dbpediaLink = document.createElement("a");
dbpediaLink.setAttribute("style","font-weight:bold; margin-left: 20px; margin-right: 20px;");
dbpediaLink.setAttribute("href","http://www.dbpedia.org/resource" + link.replace(/http:\/\/en.wikipedia.org\/wiki/, ""));
dbpediaImage = document.createElement("img");
dbpediaImage.setAttribute("style","border:none;");
dbpediaImage.setAttribute("title","DBpedia page for " + firstHeading.firstChild.nodeValue);
dbpediaImage.setAttribute("src","http://www4.wiwiss.fu-berlin.de/dbpedia/userscript/dbpedia.png");
dbpediaLink.appendChild(dbpediaImage);
firstHeading.appendChild(dbpediaLink);
}
} */
}